package com.longshine.tools.util;

import java.awt.Component;
import java.awt.Toolkit;

public class SwingUtil {

	public static void setCenter(Component c){
		int h = c.getHeight();
		int w = c.getWidth();
		int w1 = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
		int h1 =  (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
		c.setLocation((w1-w)/2, (h1-h)/2);
	}
	
	public static void setRightAndBottom(Component c){
		int h = c.getHeight();
		int w = c.getWidth();
		int w1 = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
		int h1 =  (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
		c.setLocation((w1-w), (h1-h));
	}
	
	public static void setTopCenter(Component c){
		int w = c.getWidth();
		int w1 = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
		c.setLocation((w1-w)/2, 0);
	}
}
